import { Module } from '@nestjs/common';
import { JwtConfigService } from './jwt.config.service';
import { JwtModule } from '@nestjs/jwt';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { RedisModule } from '../redis/redis.module';

@Module({
  imports: [
    JwtModule.registerAsync({
      imports: [ConfigModule],
      useFactory: (configService: ConfigService) => {
        return {
          secret: process.env.JWT_SECRET || configService.get('JWT_SECRET'),
        };
      },
    }),
    RedisModule,
  ],
  providers: [JwtConfigService],
  exports: [JwtConfigModule, JwtConfigService],
})
export class JwtConfigModule {}
